/**
 * 版权所有(C)，上海勾芒信息科技，2017，所有权利保留。
 * 
 * 项目名：	cards-web
 * 文件名：	WxMpXmlMessageEx.java
 * 模块说明：	
 * 修改历史：
 * 2017年4月4日 - Debenson - 创建。
 */

package me.chanjar.weixin.component.bean.message;

import java.io.InputStream;
import java.io.Serializable;

import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamConverter;

import me.chanjar.weixin.common.util.ToStringUtils;
import me.chanjar.weixin.common.util.xml.XStreamCDataConverter;
import me.chanjar.weixin.mp.util.xml.XStreamTransformer;

/**
 * 开放平台推送消息
 * 
 * <a href=
 * "https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1453779503&token=f4e6cc754f4b06bd2a86158a0f4353bc3b8d3454&lang=zh_CN">具体接口请查看开放平台接口文档</a>
 * 
 * @author Debenson
 * @since 0.1
 */
@XStreamAlias("xml")
public class WxComponentXmlMessage implements Serializable {
  private static final long serialVersionUID = -3586245291677274914L;

  public static WxComponentXmlMessage fromXml(String xml) {
    return XStreamTransformer.fromXml(WxComponentXmlMessage.class, xml);
  }

  public static WxComponentXmlMessage fromXml(InputStream is) {
    return XStreamTransformer.fromXml(WxComponentXmlMessage.class, is);
  }

  /** 第三方平台appid */
  @XStreamAlias("AppId")
  @XStreamConverter(value = XStreamCDataConverter.class)
  private String appId;

  /** 时间戳 */
  @XStreamAlias("CreateTime")
  private Long createTime;

  /** component_verify_ticket, */
  @XStreamAlias("InfoType")
  @XStreamConverter(value = XStreamCDataConverter.class)
  private String infoType;

  /** Ticket内容 */
  @XStreamAlias("ComponentVerifyTicket")
  @XStreamConverter(value = XStreamCDataConverter.class)
  private String componentVerifyTicket;

  /** 公众号或小程序appid */
  @XStreamAlias("AuthorizerAppid")
  @XStreamConverter(value = XStreamCDataConverter.class)
  private String authorizerAppid;

  /** 授权码，可用于换取公众号的接口调用凭据，详细见上面的说明 */
  @XStreamAlias("AuthorizationCode")
  @XStreamConverter(value = XStreamCDataConverter.class)
  private String authorizationCode;

  /** 授权码过期时间 */
  @XStreamAlias("AuthorizationCodeExpiredTime")
  private Long authorizationCodeExpiredTime;

  public String getAppId() {
    return appId;
  }

  public void setAppId(String appId) {
    this.appId = appId;
  }

  public Long getCreateTime() {
    return createTime;
  }

  public void setCreateTime(Long createTime) {
    this.createTime = createTime;
  }

  public String getInfoType() {
    return infoType;
  }

  public void setInfoType(String infoType) {
    this.infoType = infoType;
  }

  public String getComponentVerifyTicket() {
    return componentVerifyTicket;
  }

  public void setComponentVerifyTicket(String componentVerifyTicket) {
    this.componentVerifyTicket = componentVerifyTicket;
  }

  @Override
  public String toString() {
    return ToStringUtils.toSimpleString(this);
  }

  /** 推送component_verify_ticket协议 */
  public static final String INFO_TYPE_COMPONENT_VERIFY_TICKET = "component_verify_ticket";
  /** 取消授权通知 */
  public static final String INFO_TYPE_UNAUTHORIZED = "unauthorized";
  /** 授权成功通知 */
  public static final String INFO_TYPE_AUTHORIZED = "authorized";
  /** 授权更新通知 */
  public static final String INFO_TYPE_UPDATEAUTHORIZED = "updateauthorized";

}
